import DialogLib from '../lib/DialogLib.vue'
import {createApp,h} from 'vue'

interface dialogType {
    title: string;
    content: string;
    touchOverlayClose:boolean;
    complete:()=>void,
    cancel:()=>void,
}
const openModel=function(obj:dialogType){
  const {title,content,touchOverlayClose,complete,cancel}=obj
  const div = document.createElement('div')
  document.body.appendChild(div)
  const app = createApp({
    render(){
     return h(DialogLib,{visible:true,
        'onUpdate:visible':(newVisible:boolean)=>{
          if(newVisible==false){
            app.unmount()
            div.remove()
          }
        },touchOverlayClose,cancel,complete},{title,content})
    } 
  })
  app.mount(div)
}

export default openModel